import { useTheme, ThemeMode } from "../contexts/ThemeContext";

/**
 * 主题颜色工具集
 */

// 深色模式颜色
const darkColors = {
  primary: "#1DA1F2",
  background: "#15202B",
  chatBackground: "#192734",
  inputBackground: "#192734",
  inputText: "#FFFFFF",
  text: "#FFFFFF",
  secondaryText: "#8899A6",
  border: "#38444D",
  card: "#192734",
  divider: "#38444D",
  error: "#FF3B30",
  success: "#4BB543",
  warning: "#FFD700",
};

// 浅色模式颜色
const lightColors = {
  primary: "#1DA1F2",
  background: "#FFFFFF",
  chatBackground: "transparent",
  inputBackground: "#F5F8FA",
  inputText: "#14171A",
  text: "#14171A",
  secondaryText: "#657786",
  border: "#E1E8ED",
  card: "#FFFFFF",
  divider: "#E1E8ED",
  error: "#FF3B30",
  success: "#4BB543",
  warning: "#FFD700",
};

/**
 * 获取背景色
 * 根据当前主题模式返回适当的背景颜色
 */
export const getBackgroundColor = (mode: ThemeMode): string => {
  return mode === "dark" ? darkColors.background : lightColors.background;
};

/**
 * 获取文本颜色
 * 根据当前主题模式返回适当的文本颜色
 */
export const getTextColor = (mode: ThemeMode): string => {
  return mode === "dark" ? darkColors.text : lightColors.text;
};

/**
 * 获取次要文本颜色
 * 根据当前主题模式返回适当的次要文本颜色
 */
export const getSecondaryTextColor = (mode: ThemeMode): string => {
  return mode === "dark" ? darkColors.secondaryText : lightColors.secondaryText;
};

/**
 * 获取边框颜色
 * 根据当前主题模式返回适当的边框颜色
 */
export const getBorderColor = (mode: ThemeMode): string => {
  return mode === "dark" ? darkColors.border : lightColors.border;
};

/**
 * 获取卡片背景色
 * 根据当前主题模式返回适当的卡片背景颜色
 */
export const getCardColor = (mode: ThemeMode): string => {
  return mode === "dark" ? darkColors.card : lightColors.card;
};

/**
 * 获取分割线颜色
 * 根据当前主题模式返回适当的分割线颜色
 */
export const getDividerColor = (mode: ThemeMode): string => {
  return mode === "dark" ? darkColors.divider : lightColors.divider;
};

/**
 * 主题颜色钩子
 * 返回当前主题下的所有颜色值
 */
export const useThemeColors = () => {
  const { themeMode } = useTheme();

  return {
    mode: themeMode,
    colors: themeMode === "dark" ? darkColors : lightColors,
    primary: themeMode === "dark" ? darkColors.primary : lightColors.primary,
    background:
      themeMode === "dark" ? darkColors.background : lightColors.background,
    text: themeMode === "dark" ? darkColors.text : lightColors.text,
    secondaryText:
      themeMode === "dark"
        ? darkColors.secondaryText
        : lightColors.secondaryText,
    border: themeMode === "dark" ? darkColors.border : lightColors.border,
    card: themeMode === "dark" ? darkColors.card : lightColors.card,
    divider: themeMode === "dark" ? darkColors.divider : lightColors.divider,
    error: themeMode === "dark" ? darkColors.error : lightColors.error,
    success: themeMode === "dark" ? darkColors.success : lightColors.success,
    warning: themeMode === "dark" ? darkColors.warning : lightColors.warning,
    chatBackground:
      themeMode === "dark"
        ? darkColors.chatBackground
        : lightColors.chatBackground,
    inputBackground:
      themeMode === "dark"
        ? darkColors.inputBackground
        : lightColors.inputBackground,
    inputText:
      themeMode === "dark" ? darkColors.inputText : lightColors.inputText,
  };
};
